package com.jf.thread;

import java.util.Timer;

public class Test06 {
    public static void main(String[] args) {
        Timer timer = new Timer();
//        System.out.println("3秒后执行");
//        timer.schedule(new MyTimerTask(timer),3000);
        System.out.println("等待3秒后开始执行，之后每间隔1秒重复执行");
        timer.schedule(new MyTimerTask(timer),3000,1000);
        /*20秒后关闭计时器*/
        timer.schedule(new CancelTimeTask(timer),1000*20);
    }
}
